﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RENIT.DragNDropUpload.Utils
{
    public class DisposingLock : IDisposable
    {
        public bool Disposed { get; private set; }
        private Action code;

        public DisposingLock(Action disposeCode)
        {
            code = disposeCode;
            Disposed = code == null;
        }

        public void Dispose()
        {
            if (!Disposed)
            {
                code();
                Disposed = true;
            }
        }
    }
}
